package kbse_generic;



public class Stack<T> {
    private T[] stack;
    private int size;   
    
    
    public Stack(int size) 
    {
        this.stack = (T[]) new Object[size];
        this.size  = 0;
    }
    
    
    public void push(T element) throws Exception
    {
        if( element == null ) {
            throw new NullPointerException();
        }
        if( size == stack.length ) {
            throw new StapelVollException();
        }
        stack[size++] = element;
    }
    

    public T pop() throws Exception
    {
        if( size == 0 ) {
            throw new StapelLeerException();
        }
        return stack[--size];
    }   
    
    
    public boolean istVoll()
    {
        if( size == stack.length ){
            return true;
        }
        return false;
    }
    
    
    public boolean istLeer()
    {
        if( size == 0 ){
            return true;
        }
        return false;
    }
  
    
 
    
}